<?php 
session_start();
if ($_SESSION['auth'] != true && $_SESSION['rule'] != "ADMIN") {
	die('Not log in');
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Admin</title>
<link href="itelement.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="script/jquery.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready (
	function () {
		$('#addChannel').click(
			function(){
				var err = channelReq();
				if(err != ''){
					$('#status').show('fast');
					$('#status').html(err);
					return;
				}
				//add channel
				var serialize = $('form').serializeArray( );
				//alert($('form').serialize( ));
				$('#status').show('fast');
				$('#status').text('Wait server...');
				$.post("admin_operation.php?action=add_channel", serialize,
				  function(data){
					$('#status').text(data);
				  });
			}
		);
	}
);
function channelReq(){
	var br = '<br />';
	var err = '';
	if($('#title').val()==''){
		err += 'o  Title field requires'+br;
	}
	if($('#description').val()==''){
		err += 'o  Description field requires'+br;
	}
	if(err != '')err = err.substring(0,err.length-br.length);
	return err;
}
</script>
</head>
<body>
<form>
	  	  <div class="viewer-head">
		  	<div class="viewer-head-left">Add Channel </div>
			<!--<div class="viewer-head-right"><input type="button" value="reset"></div>-->
		  </div>
		  <div class="input">Title
		    *
		    <div>
    <input style="width:100%" id="title" name="title" type="text">
    </div>
</div>
		  <div class="input">
			Description
			  *
			  <div>
			  <input style="width:100%" id="description" name="description" type="text">
			</div>
		  </div>
		  <div class="input">
			Language
			  *
			  <div>
			  <select name="language">
			  	<option value="en-us">English</option>
			  	<option value="th">Thai</option>
			  	<option value="zh-cn">Chinese (Simplified)</option>
				</select>
			</div>
		  </div>
		  <div class="input">Rank
		    *
		    <div>
			  <select name="rank">
			  	<option value="1">public</option>
			  	<option value="2">member</option>
				<option value="3">secret</option>
			</select>
			</div>
		  </div>
		  <div id="status"></div>
		  <!--<input type="submit" value="&nbsp;&nbsp;add&nbsp;&nbsp;">-->
		  <input id="addChannel" type="button" value="&nbsp;&nbsp;add&nbsp;&nbsp;" />
</form>
</body>
</html>